#include<linux/module.h>
#include<linux/sched.h>
#include<linux/pid.h>
#include<linux/kthread.h>
MODULE_LICENSE("GPL");

int my_function(void *argc)
{
	printk("in the kernel thread function!\n");
	printk("the current static_prio is:%d\n",current->static_prio);

	printk("the current nice is:%d\n",task_nice(current));
	printk("the current pid is:%d\n",current->pid);
	printk("out the kernel thread function!\n");
	return 0;
}
static int __init task_nice_init(void)
{
	struct task_struct *result;
	int priority;
	printk("into task_nice_init\n");
	result=kthread_create_on_node(my_function,NULL,-1,"task_nice");
	wake_up_process(result);

	priority=task_nice(result);
	printk("the static_prio of the child thread is:%d\n",result->static_prio);
	printk("the nice of the child thread is:%d\n",priority);
	printk("the pid of new thread is:%d\n",result->pid);
	printk("the current static_prio is:%d\n",current->static_prio);

	printk("the current pid is:%d\n",current->pid);
	printk("the current nice is:%d\n",task_nice(current));
	printk("out task_nice_init.\n");
	return 0;
}
static void __exit task_nice_exit(void)
{
	printk("Goodbye task_nice\n");
}
module_init(task_nice_init);
module_exit(task_nice_exit);
